<!-- 医院_检验科室_工作组 -->
<template>
    <div style="height: 100%; width: 100%; position: relative">
        <div class="pagetop">
            <template>
                <div style="width: 100%">
                    <div>
                        <table>
                            <tr>
                                <td>快速查找</td>
                                <td>
                                    <el-input v-model="qcode" @keyup.enter.native="Search()"></el-input>
                                </td>
                                <td>医院类型</td>
                                <td>
                                    <el-select style="width: 100%" v-model="hospitaltype" @change="Search()" clearable>
                                        <el-option key="1" value="检验医院" label="检验医院"></el-option>
                                        <el-option key="2" value="送检单位" label="送检单位"></el-option>
                                        <el-option key="3" value="送检单位/检验医院" label="送检单位/检验医院"></el-option>
                                        <el-option key="4" value="外送目标医院" label="外送目标医院"></el-option>
                                    </el-select>
                                </td>
                                <td width="160" style="text-align: center">
                                    <span style="color: red; font-size: 16px; font-weight: bold">{{ AreaTxt }}<i
                                            class="el-icon-edit" style="color: red; cursor: pointer"
                                            @click="AreaEdit()"></i></span>
                                </td>
                                <td v-if="isbis != '1'">采购中心</td>
                                <td v-if="isbis != '1'">
                                    <el-select style="width: 100%" v-model="InvVal" @change="OrgSearch()" clearable>
                                        <el-option :key="item.invorgid" :value="item.invorgid" :label="item.orgname"
                                            v-for="item in InvOption"></el-option>
                                    </el-select>
                                </td>
                                <td v-if="isbis != '1'">设备中心</td>
                                <td v-if="isbis != '1'">
                                    <el-select style="width: 100%" v-model="DevVal" @change="OrgSearch()" clearable>
                                        <el-option :key="item.devorgid" :value="item.devorgid" :label="item.orgname"
                                            v-for="item in DevOption"></el-option>
                                    </el-select>
                                </td>
                                <td v-if="isbis != '1'">文档中心</td>
                                <td v-if="isbis != '1'">
                                    <el-select style="width: 100%" v-model="DocVal" @change="OrgSearch()" clearable>
                                        <!-- <el-option :key="item.invorgid" :value="item.invorgid" :label="item.orgname" v-for="item in DocOption"></el-option> -->
                                    </el-select>
                                </td>
                            </tr>
                        </table>
                    </div>
                    <div style="float: right; width: 100%" ref="buttondiv">
                        <table style="width: 20%; float: right">
                            <tr>
                                <td style="text-align: left">
                                    <el-button @click="FindHosp(), (isFirstLoadingHosp = false)"
                                        icon="el-icon-refresh-right" v-has="'PINQUERY'">刷新</el-button>
                                </td>
                                <td style="text-align: left">
                                    <el-button @click="OpenDialog(4, 1)" icon="el-icon-edit" v-has="'PMODIFY'"
                                        v-show="!isnoarea">外送机构</el-button>
                                </td>
                                <td style="text-align: left">
                                    <el-button @click="OpenDialog(1, 1)" icon="el-icon-plus" v-has="'PADD'"
                                        v-show="issuper">新增</el-button>
                                </td>
                                <td style="text-align: left">
                                    <el-button @click="OpenDialog(2, 1)" icon="el-icon-edit" v-has="'PMODIFY'"
                                        v-show="issuper">修改</el-button>
                                </td>
                                <td style="text-align: left">
                                    <el-button @click="OpenDialog(3, 1)" icon="el-icon-delete" v-has="'PDELETE'"
                                        v-show="issuper">删除</el-button>
                                </td>
                                <td style="text-align: left; margin-left: 20px">
                                    <el-button @click="QueryCodena()" icon="el-icon-edit"
                                        v-show="!isarea && issuper">单位名称</el-button>
                                </td>
                                <td style="text-align: left">
                                    <el-button @click="QueryRegCode()" icon="el-icon-goods"
                                        v-show="issuper">系统注册</el-button>
                                </td>
                            </tr>
                        </table>
                    </div>
                </div>
            </template>
        </div>
        <div class="pagecenter">
            <div class="middle-center">
                <div ref="xTable1Div" style="height: 100%">
                    <vxe-table :data="tableDataHosp" :loading="loadingHosp" :keyboard-config="keyConfig"
                        :keyboard-local-config="keyLocalConfig" :row-class-name="rowClassName"
                        :checkbox-config="selectConfig" :sort-config="{ trigger: 'cell' }"
                        @current-change="HospCurrentChangeEvent" border fit height="auto" header-align="center"
                        highlight-current-row highlight-hover-row highlight-hover-column ref="xTable1" resizable show-footer
                        :footer-method="footerMethod" show-header-overflow="tooltip" show-overflow="tooltip" size="mini"
                        stripe>
                        <vxe-table-column type="index" title="序号" width="35" align="center"></vxe-table-column>
                        <vxe-table-column :field="items.field" :key="items.field" :title="items.title" :width="items.width"
                            sortable v-for="items in tableColumnHosp"></vxe-table-column>
                    </vxe-table>
                </div>
            </div>
            <div class="middle-right">
                <div style="height: 50%; font-size: 12px">
                    <div style="height: 100%">
                        <div ref="xTable2Div" style="height: 100%">
                            <vxe-table :data="tableDataDept" :loading="loadingDept" :keyboard-config="keyConfig"
                                :keyboard-local-config="keyLocalConfig" :row-class-name="rowClassName"
                                :checkbox-config="selectConfig" :sort-config="{ trigger: 'cell' }"
                                @current-change="DeptCurrentChangeEvent" border fit height="auto" header-align="center"
                                highlight-current-row highlight-hover-row highlight-hover-column ref="xTable2" resizable
                                show-header-overflow="tooltip" show-overflow="tooltip" size="mini" stripe>
                                <vxe-table-column :field="items.field" :key="items.field" :title="items.title"
                                    :width="items.width" sortable v-for="items in tableColumnDept"></vxe-table-column>
                            </vxe-table>
                            <div class="table-bottom">
                                <table style="width: 100%">
                                    <tr>
                                        <td width="500px"></td>
                                        <td style="text-align: left">
                                            <el-button @click="FindDept(), (isFirstLoadingDept = false)"
                                                style="background-color: #e6e6e6; color: black"
                                                icon="el-icon-refresh-right">刷新</el-button>
                                        </td>
                                        <td style="text-align: left">
                                            <el-button @click="OpenDialog(1, 2)"
                                                style="background-color: #e6e6e6; color: black" icon="el-icon-plus"
                                                v-has="'PADD'">新增科室</el-button>
                                        </td>
                                        <td style="text-align: left">
                                            <el-button @click="OpenDialog(2, 2)"
                                                style="background-color: #e6e6e6; color: black" icon="el-icon-edit"
                                                v-has="'PMODIFY'">修改科室</el-button>
                                        </td>
                                        <td style="text-align: left">
                                            <el-button @click="OpenDialog(3, 2)"
                                                style="background-color: #e6e6e6; color: black" icon="el-icon-delete"
                                                v-has="'PDELETE'">删除科室</el-button>
                                        </td>
                                    </tr>
                                </table>
                            </div>

                        </div>
                    </div>
                </div>
                <div style="height: 50%; font-size: 12px">
                    <div style="height: 100%">
                        <div ref="xTable3Div" style="height: 100%">
                            <vxe-table :data="tableDataGroup" :loading="loadingGroup" :keyboard-config="keyConfig"
                                :keyboard-local-config="keyLocalConfig" :row-class-name="rowClassName"
                                :checkbox-config="selectConfig" :sort-config="{ trigger: 'cell' }"
                                @current-change="GroupCurrentChangeEvent" border fit height="auto" header-align="center"
                                highlight-current-row highlight-hover-row highlight-hover-column ref="xTable3" resizable
                                show-header-overflow="tooltip" show-overflow="tooltip" size="mini" stripe>
                                <vxe-table-column :field="items.field" :key="items.field" :title="items.title"
                                    :width="items.width" sortable v-for="items in tableColumnGroup"></vxe-table-column>
                            </vxe-table>
                            <div class="table-bottom2">
                                <table style="width: 100%">
                                    <tr>
                                        <td width="500px"></td>
                                        <td style="text-align: left">
                                            <el-button @click="FindGroup(), (isFirstLoadingGroup = false)"
                                                style="background-color: #e6e6e6; color: black"
                                                icon="el-icon-refresh-right">刷新</el-button>
                                        </td>
                                        <td style="text-align: left">
                                            <el-button @click="OpenDialog(1, 3)"
                                                style="background-color: #e6e6e6; color: black" icon="el-icon-plus"
                                                v-has="'PADD'">新增检验组</el-button>
                                        </td>
                                        <td style="text-align: left">
                                            <el-button @click="OpenDialog(2, 3)"
                                                style="background-color: #e6e6e6; color: black" icon="el-icon-edit"
                                                v-has="'PMODIFY'">修改检验组</el-button>
                                        </td>
                                        <td style="text-align: left">
                                            <el-button @click="OpenDialog(3, 3)"
                                                style="background-color: #e6e6e6; color: black" icon="el-icon-delete"
                                                v-has="'PDELETE'">删除检验组</el-button>
                                        </td>
                                    </tr>
                                </table>
                            </div>

                        </div>
                    </div>
                </div>
            </div>
        </div>
        <el-dialog v-el-drag-dialog :close-on-click-modal="false" :title="Organdialogtitle" :visible.sync="OrgandialogForm"
            width="1150px">
            <rm-layout-right splitcolor="#ffffff" :splitwidth="3" :fixsize="800" :candrag="false" style="height: 600px">
                <template v-slot:fix>
                    <el-form style="height: 100%" label-width="auto" type="border-card" ref="organitem" :model="OrganInfo"
                        @submit.native.prevent>
                        <table>
                            <tr>
                                <td style="color: red">选择医院</td>
                                <td>
                                    <rm-ddl-common datatype="hospitalorgan" dataname="医院" ref="organcode"
                                        v-model="OrganInfo.organcode" width="100%" @change="organcodeChange"
                                        :disabled="canchangehosp" :uncludehospcode="CurrentHospcode"></rm-ddl-common>
                                </td>
                                <td>访问地址</td>
                                <td>
                                    <el-input style="width: 100%" v-model="OrganInfo.accaddress" ref="accaddress"
                                        @input="HasChange"></el-input>
                                </td>
                            </tr>
                            <tr>
                                <td>报告单元（普通）</td>
                                <td>
                                    <!-- <el-input style="width: 100%" v-model="OrganInfo.downrptunitid1" ref="downrptunitid1" readonly :disabled="true"></el-input> -->
                                    <rm-ddl-rptunit @change="rptunitchange1" v-model="OrganInfo.downrptunitid1"
                                        reporttype="10" width="100%" clearable></rm-ddl-rptunit>
                                </td>
                                <td>报告单元（微生物）</td>
                                <td>
                                    <!-- <el-input style="width: 100%" v-model="OrganInfo.downrptunitid2" ref="downrptunitid2" readonly :disabled="true"></el-input> -->
                                    <rm-ddl-rptunit @change="rptunitchange2" v-model="OrganInfo.downrptunitid2"
                                        reporttype="20" width="100%" clearable></rm-ddl-rptunit>
                                </td>
                            </tr>
                            <tr>
                                <td>自定义字段1</td>
                                <td colspan="3">
                                    <el-input style="width: 100%" @dblclick.native="customefieldDialog('1')"
                                        placeholder="双击弹窗输入" v-model="OrganInfo.customefield1" ref="customefield1"
                                        @input="HasChange"></el-input>
                                </td>
                            </tr>
                            <tr>
                                <td>自定义字段2</td>
                                <td colspan="3">
                                    <el-input style="width: 100%" @dblclick.native="customefieldDialog('2')"
                                        placeholder="双击弹窗输入" v-model="OrganInfo.customefield2" ref="customefield2"
                                        @input="HasChange"></el-input>
                                </td>
                            </tr>
                            <tr>
                                <td>自定义字段3</td>
                                <td colspan="3">
                                    <el-input style="width: 100%" @dblclick.native="customefieldDialog('3')"
                                        placeholder="双击弹窗输入" v-model="OrganInfo.customefield3" ref="customefield3"
                                        @input="HasChange"></el-input>
                                </td>
                            </tr>
                            <tr>
                                <td>自定义字段4</td>
                                <td colspan="3">
                                    <el-input style="width: 100%" @dblclick.native="customefieldDialog('4')"
                                        placeholder="双击弹窗输入" v-model="OrganInfo.customefield4" ref="customefield4"
                                        @input="HasChange"></el-input>
                                </td>
                            </tr>
                            <tr>
                                <td>自定义字段5</td>
                                <td colspan="3">
                                    <el-input style="width: 100%" @dblclick.native="customefieldDialog('5')"
                                        placeholder="双击弹窗输入" v-model="OrganInfo.customefield5" ref="customefield5"
                                        @input="HasChange"></el-input>
                                </td>
                            </tr>
                            <tr>
                                <td>自定义字段6</td>
                                <td colspan="3">
                                    <el-input style="width: 100%" @dblclick.native="customefieldDialog('6')"
                                        placeholder="双击弹窗输入" v-model="OrganInfo.customefield6" ref="customefield6"
                                        @input="HasChange"></el-input>
                                </td>
                            </tr>
                            <tr>
                                <td>自定义字段7</td>
                                <td colspan="3">
                                    <el-input style="width: 100%" @dblclick.native="customefieldDialog('7')"
                                        placeholder="双击弹窗输入" v-model="OrganInfo.customefield7" ref="customefield7"
                                        @input="HasChange"></el-input>
                                </td>
                            </tr>
                            <tr>
                                <td>自定义字段8</td>
                                <td colspan="3">
                                    <el-input style="width: 100%" @dblclick.native="customefieldDialog('8')"
                                        placeholder="双击弹窗输入" v-model="OrganInfo.customefield8" ref="customefield8"
                                        @input="HasChange"></el-input>
                                </td>
                            </tr>
                            <tr>
                                <td>自定义字段9</td>
                                <td colspan="3">
                                    <el-input style="width: 100%" @dblclick.native="customefieldDialog('9')"
                                        placeholder="双击弹窗输入" v-model="OrganInfo.customefield9" ref="customefield9"
                                        @input="HasChange"></el-input>
                                </td>
                            </tr>
                            <tr>
                                <td>自定义字段10</td>
                                <td colspan="3">
                                    <el-input style="width: 100%" @dblclick.native="customefieldDialog('10')"
                                        placeholder="双击弹窗输入" v-model="OrganInfo.customefield10" ref="customefield10"
                                        @input="HasChange"></el-input>
                                </td>
                            </tr>
                        </table>
                    </el-form>
                </template>
                <div ref="XTableOrganDiv" style="height: 600px; width: auto" id="Vxe-organ">
                    <vxe-table ref="xTableOrgan" height="auto" size="mini" :data.sync="hotableData"
                        :checkbox-config="{ reserve: true }" :sort-config="{ trigger: 'cell' }"
                        show-header-overflow="tooltip" :keyboard-local-config="keyLocalConfig" show-overflow="tooltip"
                        highlight-current-row highlight-hover-row highlight-hover-column resizable header-align="center"
                        @current-change="OrganCurrentChangeEvent" stripe border width="300px">
                        <vxe-table-column key="organcode" field="organcode" title="医院代码" sortable width="120px"
                            show-overflow></vxe-table-column>
                        <vxe-table-column key="organname" field="organname" title="医院名称" sortable width="300px"
                            show-overflow></vxe-table-column>
                        <!-- <vxe-table-column key="hosporganid" field="hosporganid" title="ID" sortable width="50px" show-overflow></vxe-table-column>
                            <vxe-table-column key="accaddress" field="accaddress" width="100px" title="访问地址"></vxe-table-column>
                            <vxe-table-column key="downrptunitid1" field="downrptunitid1" width="80px" title="报告单元(普通)"></vxe-table-column>
                            <vxe-table-column key="downrptunitid2" field="downrptunitid2" width="80px"  title="报告单元（微生物）"></vxe-table-column>
                            <vxe-table-column key="customefield1" field="customefield1" width="80px" title="自定义字段1"></vxe-table-column>
                            <vxe-table-column key="customefield2" field="customefield2" width="80px" title="自定义字段2"></vxe-table-column>
                            <vxe-table-column key="customefield3" field="customefield3" width="80px" title="自定义字段3"></vxe-table-column>
                            <vxe-table-column key="customefield4" field="customefield4" width="80px" title="自定义字段4"></vxe-table-column>
                            <vxe-table-column key="customefield5" field="customefield5" width="80px" title="自定义字段5"></vxe-table-column>
                            <vxe-table-column key="customefield6" field="customefield6" width="80px" title="自定义字段6"></vxe-table-column>
                            <vxe-table-column key="customefield7" field="customefield7" width="80px" title="自定义字段7"></vxe-table-column>
                            <vxe-table-column key="customefield8" field="customefield8" width="80px" title="自定义字段8"></vxe-table-column>
                            <vxe-table-column key="customefield9" field="customefield9" width="80px" title="自定义字段9"></vxe-table-column>
                            <vxe-table-column key="customefield10" field="customefield10" width="80px" title="自定义字段10"></vxe-table-column> -->
                    </vxe-table>
                </div>
            </rm-layout-right>

            <div style="text-align: right; padding-top: 5px">
                <el-button @click="btnadd()" icon="el-icon-plus" v-has="'PADD'" :disabled="changeflag">新增</el-button>
                <el-button @click="btndelete()" icon="el-icon-delete" v-has="'PADD'" :disabled="changeflag">删除</el-button>
                <el-button @click="CommiTOrgantips()" icon="el-icon-document" v-has="'PMODIFY'"
                    :disabled="!changeflag">保存</el-button>
                <el-button @click="CancelChange()" icon="el-icon-close" :disabled="!changeflag">取消</el-button>
            </div>
        </el-dialog>
        <el-dialog width="800px" v-el-drag-dialog :append-to-body="true" :title="customeFieldTitle" ref="customeDialog"
            :visible.sync="customeFDialog">
            <div>
                <el-input type="textarea" rows="8" id="customeTextarea" v-model="textareamodel"></el-input>
            </div>
            <div style="text-align: right; margin-top: 5px">
                <el-button @click="customeFieldConfirm()">确 定</el-button>
                <el-button @click="customeFDialog = false">取 消</el-button>
            </div>
        </el-dialog>
        <!-- <el-dialog v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" title="请选择报告单元" :visible.sync="rptunitdialog">
            <rm-pop-rptunit @change="rptunitchange" @cancel="rptunitdialog=false;" prgno="MNG116" datatype="rptunit" :appendtobody="true"></rm-pop-rptunit>
        </el-dialog> -->
        <el-dialog v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" title="请选择报告单元">
            <rm-pop-rptunit prgno="MNG116" datatype="rptunit" :appendtobody="true"></rm-pop-rptunit>
        </el-dialog>
        <el-dialog v-el-drag-dialog :close-on-click-modal="false" :title="Hospdialogtitle" :visible.sync="HospdialogForm"
            width="650px">
            <el-form :inline="true" :model="HospInfo" @submit.native.prevent label-width="auto" ref="form1"
                style="border: 1px solid #ccc">
                <table>
                    <tr>
                        <td style="color: red">医院代码</td>
                        <td colspan="3">
                            <el-input style="width: 100%" v-model="HospInfo.hospcode" ref="hospcode"
                                @keyup.enter.native="autofocusEvent($event, 'hospcode')"
                                :disabled="actionflag == 2"></el-input>
                        </td>
                    </tr>
                    <tr>
                        <td style="color: red">医院机构代码</td>
                        <td colspan="3">
                            <el-input style="width: 100%" v-model="HospInfo.hosporgid" ref="hospcode"
                                @keyup.enter.native="autofocusEvent($event, 'hospcode')"
                                :disabled="actionflag == 2"></el-input>
                        </td>
                    </tr>
                    <tr>
                        <td style="color: red">送检单位/医院名称</td>
                        <td colspan="3">
                            <el-input :style="actionflag == 2 ? 'width:calc(100% - 65px)' : 'width:100%'"
                                :disabled="actionflag == 2" v-model="HospInfo.hospitalname" ref="hospitalname"
                                @change="mdlnameChange"
                                @keyup.enter.native="autofocusEvent($event, 'hospitalname')"></el-input>
                            <el-button style="margin-left: 5px" v-show="actionflag == 2"
                                @click="(hospname = HospInfo.hospitalname), (RegCode = ''), (dialogNameChangeVisible = true)">修
                                改</el-button>
                        </td>
                    </tr>
                    <tr>
                        <td>医院简称</td>
                        <td colspan="3">
                            <el-input style="width: 100%" v-model="HospInfo.hospitalna" ref="hospitalna"
                                @keyup.enter.native="autofocusEvent($event, 'hospitalna')"></el-input>
                        </td>
                    </tr>
                    <tr>
                        <td>医院类型</td>
                        <td>
                            <el-select style="width: 100%" v-model="HospInfo.hospitaltype" ref="hospitaltype"
                                @keyup.enter.native="autofocusEvent($event, 'hospitaltype')">
                                <el-option key="1" value="1" label="检验医院"></el-option>
                                <el-option key="2" value="2" label="送检单位"></el-option>
                                <el-option key="3" value="3" label="检验医院/送检单位"></el-option>
                                <el-option key="4" value="4" label="外送目标医院"></el-option>
                            </el-select>
                        </td>
                        <td>医院级别</td>
                        <td>
                            <el-select style="width: 100%" v-model="HospInfo.hospitalclass" ref="hospitalclass"
                                @keyup.enter.native="autofocusEvent($event, 'hospitalclass')">
                                <el-option v-for="item in hospclass" :key="item.codeno" :value="item.codeno"
                                    :label="item.codena"></el-option>
                            </el-select>
                        </td>
                    </tr>
                    <tr>
                        <td>外部代码</td>
                        <td>
                            <el-input style="width: 100%" v-model="HospInfo.externalcode" ref="hospexternalcode"
                                @keyup.enter.native="autofocusEvent($event, 'hospexternalcode')"></el-input>
                        </td>
                        <td colspan="2" style="text-align: left">提示：条码前缀(或后缀)</td>
                    </tr>
                    <tr>
                        <td>联系人</td>
                        <td>
                            <el-input style="width: 100%" v-model="HospInfo.contactman" ref="hospcotactman"
                                @keyup.enter.native="autofocusEvent($event, 'hospcotactman')"></el-input>
                        </td>
                        <td>物流人员</td>
                        <td>
                            <rm-ddl-common datatype="userinfo" dataname="用户" v-model="HospInfo.logisticman" width="200px"
                                :appendtobody="true"
                                @keyup.enter.native="autofocusEvent($event, 'hosplogisticman')"></rm-ddl-common>
                        </td>
                    </tr>
                    <tr>
                        <td>联系电话</td>
                        <td>
                            <el-input style="width: 100%" v-model="HospInfo.telnum" ref="hosptelnum"
                                @keyup.enter.native="autofocusEvent($event, 'hosptelnum')"></el-input>
                        </td>
                        <td>医院组</td>
                        <td>
                            <el-select style="width: 100%" v-model="HospInfo.hospgroupno" ref="hospgroupno"
                                @keyup.enter.native="autofocusEvent($event, 'hospgroupno')">
                                <el-option v-for="item in hospgroup" :key="item.codeno" :value="item.codeno"
                                    :label="item.codena"></el-option>
                            </el-select>
                        </td>
                    </tr>
                    <tr>
                        <td>地址</td>
                        <td colspan="3">
                            <el-input style="width: 100%" v-model="HospInfo.address" ref="hospaddress"
                                @keyup.enter.native="autofocusEvent($event, 'hospaddress')"></el-input>
                        </td>
                    </tr>
                    <tr>
                        <td>位置</td>
                        <td colspan="3">
                            <el-input style="width: calc(100% - 45px)" v-model="HospInfo.mappos" ref="hospmappos"
                                @keyup.enter.native="autofocusEvent($event, 'hospaddress')"></el-input>
                            <el-button @click="ChooseFromMap" style="margin-left: 5px">选择</el-button>
                        </td>
                    </tr>
                    <tr>
                        <td>主页</td>
                        <td colspan="3">
                            <el-input style="width: 100%" v-model="HospInfo.homepage" ref="hosphomepage"
                                @keyup.enter.native="autofocusEvent($event, 'hosphomepage')"></el-input>
                        </td>
                    </tr>
                    <tr>
                        <td>电子邮件</td>
                        <td>
                            <el-input style="width: 100%" v-model="HospInfo.email" ref="hospemail"
                                @keyup.enter.native="autofocusEvent($event, 'hospemail')"></el-input>
                        </td>
                        <td>序号</td>
                        <td>
                            <el-input style="width: 100%" v-model="HospInfo.seq" ref="hospseq"
                                @keyup.enter.native="autofocusEvent($event, 'hospseq')"></el-input>
                        </td>
                    </tr>
                    <tr>
                        <td>备注说明</td>
                        <td colspan="3">
                            <el-input type="textarea" :row="2" style="width: 100%" v-model="HospInfo.description"
                                ref="hospdesc" @keyup.enter.native="autofocusEvent($event, 'hospdesc')"></el-input>
                        </td>
                    </tr>
                    <tr>
                        <td>需要报告数据类型</td>
                        <td>
                            <el-select style="width: 100%" v-model="HospInfo.backrptkind" ref="hospbackrptkind"
                                @keyup.enter.native="autofocusEvent($event, 'hospbackrptkind')">
                                <el-option key="0" value="0" label="不需要数据"></el-option>
                                <el-option key=" 1" value="1" label="仅报告数据"></el-option>
                                <el-option key=" 2" value="2" label="仅pdf报告"></el-option>
                                <el-option key="3" value="3" label="数据+pdf"></el-option>
                            </el-select>
                        </td>
                        <td>拼音码</td>
                        <td>
                            <el-input style="width: 100%" v-model="HospInfo.inputcode" ref="hospinputcode"
                                @keyup.enter.native="autofocusEvent($event, 'hospinputcode')"></el-input>
                        </td>
                    </tr>
                    <tr>
                        <td>报告单标题</td>
                        <td>
                            <el-input style="width: 100%" v-model="HospInfo.reporttitle" ref="hosprpttitle"
                                @keyup.enter.native="autofocusEvent($event, 'hosprpttitle')"></el-input>
                        </td>
                        <td>字典前缀</td>
                        <td>
                            <el-input style="width: 100%" v-model="HospInfo.dicthead" ref="dicthead"
                                @keyup.enter.native="autofocusEvent($event, 'dicthead')"></el-input>
                        </td>
                    </tr>
                    <tr>
                        <td>对应执行科室</td>
                        <td colspan="2">
                            <rm-ddl-common datatype="dept" dataname="科室" v-model="HospInfo.perform_deptno"
                                ref="perform_deptno" :appendtobody="true"
                                @keyup.enter.native="autofocusEvent($event, 'perform_deptno')"></rm-ddl-common>
                        </td>
                        <td style="text-align: left">
                            <el-checkbox v-model="HospInfo.usesecoption">独立使用系统选项</el-checkbox>
                        </td>
                    </tr>
                    <tr>
                        <td>所属上级单位</td>
                        <td>
                            <rm-ddl-common datatype="hospital" dataname="医院" v-model="HospInfo.parentid" width="200px"
                                @keyup.enter.native="autofocusEvent($event, 'hospparentid')"></rm-ddl-common>
                        </td>
                        <td>血库执行组</td>
                        <td>
                            <rm-ddl-common datatype="bldlabgroup" dataname="血库组" v-model="HospInfo.bldgroupid"
                                ref="hospbldgroupid" :appendtobody="true"
                                @keyup.enter.native="autofocusEvent($event, 'hospbldgroupid')"></rm-ddl-common>
                        </td>
                    </tr>
                    <tr>
                        <td>所属区域</td>
                        <td>
                            <rm-ddl-common datatype="region" dataname="区域" v-model="HospInfo.regionid" width="200px"
                                @keyup.enter.native="autofocusEvent($event, 'regionid')"></rm-ddl-common>
                        </td>
                        <td>条码前缀</td>
                        <td>
                            <el-input style="width: 100%" v-model="HospInfo.barheader" ref="barheader"
                                @keyup.enter.native="autofocusEvent($event, 'barheader')"></el-input>
                        </td>
                    </tr>
                    <tr>
                        <td>流水号长度</td>
                        <td>
                            <el-input style="width: 100%" oninput="value=value.replace(/[^\d]/g,'')"
                                v-model="HospInfo.barseqlen" ref="barseqlen"
                                @keyup.enter.native="autofocusEvent($event, 'barseqlen')"></el-input>
                        </td>
                        <td>营业状态</td>
                        <td>
                            <rm-ddl-common v-model="HospInfo.businessstat" datatype="seccode" kindno="businessstat"
                                kindname="营业状态" dataname="营业状态" width="100%"></rm-ddl-common>
                        </td>
                    </tr>
                    <tr>
                        <td>备用1</td>
                        <td>
                            <el-input style="width: 100%" v-model="HospInfo.reserve1" ref="reserve1"
                                @keyup.enter.native="autofocusEvent($event, 'reserve1')"></el-input>
                        </td>
                        <td>备用2</td>
                        <td>
                            <el-input style="width: 100%" v-model="HospInfo.reserve2" ref="reserve2"
                                @keyup.enter.native="autofocusEvent($event, 'reserve2')"></el-input>
                        </td>
                    </tr>
                    <tr>
                        <td>备用3</td>
                        <td>
                            <el-input style="width: 100%" v-model="HospInfo.reserve3" ref="reserve3"
                                @keyup.enter.native="autofocusEvent($event, 'reserve3')"></el-input>
                        </td>
                        <td></td>
                        <td>
                        </td>
                    </tr>
                </table>
            </el-form>
            <div style="text-align: right; padding-top: 5px">
                <el-button @click="CommitTips()">确定</el-button>
                <el-button @click="HospdialogForm = false">取消</el-button>
            </div>
        </el-dialog>

        <el-dialog v-el-drag-dialog :close-on-click-modal="false" :title="Deptdialogtitle" :visible.sync="DeptdialogForm"
            width="650px">
            <el-form :inline="true" :model="DeptInfo" @submit.native.prevent label-width="auto" ref="form2"
                style="border: 1px solid #ccc">
                <table style="width: 100%">
                    <tr>
                        <td style="color: red">检验科室代码</td>
                        <td>
                            <el-input style="width: 100%" v-model="DeptInfo.labdeptcode" ref="deptcode"
                                @keyup.enter.native="autofocusEvent($event, 'deptcode')" :disabled="isDisable"></el-input>
                        </td>
                    </tr>
                    <tr>
                        <td style="color: red">检验科室名称</td>
                        <td>
                            <el-input style="width: 100%" v-model="DeptInfo.labdeptname" ref="deptname"
                                @change="mdlnameChange" @keyup.enter.native="autofocusEvent($event, 'deptname')"></el-input>
                        </td>
                    </tr>
                    <tr>
                        <td>对应采购中心</td>
                        <td>
                            <el-select style="width: 100%" v-model="DeptInfo.invorgid" clearable>
                                <el-option v-if="isarea" value="-1" label="全局"></el-option>
                                <el-option :key="item.invorgid" :value="item.invorgid" :label="item.orgname"
                                    v-for="item in InvOption"></el-option>
                            </el-select>
                        </td>
                    </tr>
                    <tr>
                        <td>对应设备中心</td>
                        <td>
                            <el-select style="width: 100%" v-model="DeptInfo.devorgid" clearable>
                                <el-option :key="item.devorgid" :value="item.devorgid" :label="item.orgname"
                                    v-for="item in DevOption"></el-option>
                            </el-select>
                        </td>
                    </tr>
                    <!-- <tr>
                        <td>对应文档中心</td>
                        <td>
                            <el-select style="width:100%;" v-model="DeptInfo.docorgid" clearable>
                                <el-option :key="item.docorgid" :value="item.docorgid" :label="item.orgname" v-for="item in DocOption"></el-option>
                            </el-select>
                        </td>
                    </tr> -->
                    <tr>
                        <td>备注说明</td>
                        <td>
                            <el-input type="textarea" :row="2" style="width: 100%" v-model="DeptInfo.description"
                                ref="deptdesc" @keyup.enter.native="autofocusEvent($event, 'deptdesc')"></el-input>
                        </td>
                    </tr>
                    <tr>
                        <td>输入码</td>
                        <td>
                            <el-input style="width: 100%" v-model="DeptInfo.inputcode" ref="deptinputcode"
                                @keyup.enter.native="autofocusEvent($event, 'deptinputcode')"></el-input>
                        </td>
                    </tr>
                </table>
            </el-form>
            <div style="text-align: right; padding-top: 5px">
                <el-button @click="CommitTips()">确定</el-button>
                <el-button @click="DeptdialogForm = false">取消</el-button>
            </div>
        </el-dialog>

        <el-dialog v-el-drag-dialog :close-on-click-modal="false" :title="Groupdialogtitle" :visible.sync="GroupdialogForm"
            width="650px">
            <el-form :inline="true" :model="GroupInfo" @submit.native.prevent label-width="auto" ref="form"
                style="border: 1px solid #ccc">
                <table>
                    <tr>
                        <td style="color: red">检验工作组代码</td>
                        <td>
                            <el-input style="width: 100%" v-model="GroupInfo.labgroupcode" ref="groupcode"
                                @keyup.enter.native="autofocusEvent($event, 'inter')"></el-input>
                        </td>
                        <td style="color: red">检验工作组ID</td>
                        <td>
                            <el-input style="width: 100%" v-model="GroupInfo.labgroupid" disabled></el-input>
                        </td>
                    </tr>
                    <tr>
                        <td style="color: red">检验工作组名称</td>
                        <td>
                            <el-input style="width: 100%" v-model="GroupInfo.labgroupname" ref="groupname"
                                @change="mdlnameChange"
                                @keyup.enter.native="autofocusEvent($event, 'groupname')"></el-input>
                        </td>
                        <td>BI统计名称</td>
                        <td>
                            <el-input style="width: 100%" v-model="GroupInfo.bilabgroupname" ref="groupnamebi"
                                @keyup.enter.native="autofocusEvent($event, 'groupnamebi')"></el-input>
                        </td>
                    </tr>
                    <tr>
                        <td>默认执行科室</td>
                        <td>
                            <rm-ddl-common datatype="dept" dataname="科室" v-model="GroupInfo.performby" ref="performby"
                                :appendtobody="true"
                                @keyup.enter.native="autofocusEvent($event, 'groupperformby')"></rm-ddl-common>
                        </td>
                        <td>序号</td>
                        <td>
                            <el-input style="width: 100%" v-model="GroupInfo.seq" ref="groupid"
                                @keyup.enter.native="autofocusEvent($event, 'groupseq')"></el-input>
                        </td>
                    </tr>
                    <tr>
                        <td>默认HIS计价工号</td>
                        <td>
                            <rm-ddl-common datatype="doctor" dataname="医生" v-model="GroupInfo.hispriceman" ref="hispriceman"
                                :appendtobody="true"
                                @keyup.enter.native="autofocusEvent($event, 'grouphisman')"></rm-ddl-common>
                        </td>
                    </tr>
                    <tr>
                        <td>备注</td>
                        <td>
                            <el-input style="width: 100%" v-model="GroupInfo.description" ref="description"
                                @keyup.enter.native="autofocusEvent($event, 'groupdesc')"></el-input>
                        </td>
                    </tr>
                    <tr>
                        <td>输入码</td>
                        <td>
                            <el-input style="width: 100%" v-model="GroupInfo.inputcode" ref="groupinputcode"
                                @keyup.enter.native="autofocusEvent($event, 'groupinputcode')"></el-input>
                        </td>
                    </tr>
                    <tr>
                        <td>业务类型</td>
                        <td>
                            <div>
                                <el-radio-group v-model="GroupInfo.transtype" size="mini">
                                    <el-radio-button label="检验组"></el-radio-button>
                                    <el-radio-button label="细菌组"></el-radio-button>
                                    <el-radio-button label="血库组"></el-radio-button>
                                </el-radio-group>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>标本号前缀</td>
                        <td>
                            <el-input style="width: 100%" v-model="GroupInfo.matchnohead" ref="groupmatchnohead"
                                @keyup.enter.native="autofocusEvent($event, 'matchnohead')"></el-input>
                        </td>
                    </tr>
                    <tr>
                        <td>标本库可选的号段<br />(竖线"|"隔开)</td>
                        <td>
                            <el-input style="width: 100%" v-model="GroupInfo.libnoheads" ref="grouplibnoheads"
                                @keyup.enter.native="autofocusEvent($event, 'inter')"></el-input>
                        </td>
                    </tr>
                </table>
            </el-form>
            <div style="text-align: right; padding-top: 5px">
                <el-button @click="CommitTips()">确定</el-button>
                <el-button @click="GroupdialogForm = false">取消</el-button>
            </div>
        </el-dialog>

        <el-dialog title="提示" :visible.sync="dialogDelVisible" width="30%">
            <span class="el-icon-info">确定删除{{ DelItem }}<b style="color: red">{{ Delname }}</b>的记录吗?</span>
            <span slot="footer" class="dialog-footer">
                <el-button @click="CommitTips()">确定</el-button>
                <el-button @click="dialogDelVisible = false" :autofocus="true">取消</el-button>
            </span>
        </el-dialog>

        <el-dialog title="提示" :visible.sync="dialogOrganDelVisible" width="30%">
            <span class="el-icon-info">确定删除<b style="color: red">{{ Delname }}</b>的记录吗?</span>
            <span slot="footer" class="dialog-footer">
                <el-button @click="CommiTOrgantips()">确定</el-button>
                <el-button @click="dialogOrganDelVisible = false" :autofocus="true">取消</el-button>
            </span>
        </el-dialog>

        <el-dialog title="系统注册" class="change-pop" v-el-drag-dialog :close-on-click-modal="false"
            :visible.sync="dialogSysRegVisible" width="60%">
            <div>
                <table style="width: 100%">
                    <tr>
                        <td :style="{ color: reghospinfo.indexOf('未授权') > -1 ? 'red' : 'black', textAlign: 'left' }">
                            {{ reghospinfo }}
                        </td>
                        <td>
                            <table style="float: right; width: 20%">
                                <tr>
                                    <td style="text-align: left">
                                        <el-button @click="QueryRegCode()">刷新</el-button>
                                    </td>
                                    <td>
                                        <el-button @click="opendialogSysRegCode()">输入注册码</el-button>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
            </div>
            <div>
                <vxe-table :data="tableDataReg" :loading="loadingReg" :keyboard-config="keyConfig"
                    :keyboard-local-config="keyLocalConfig" :row-class-name="rowClassName" :checkbox-config="selectConfig"
                    :sort-config="{ trigger: 'cell' }" border fit height="500px" header-align="center" highlight-current-row
                    highlight-hover-row highlight-hover-column ref="xTableReg" resizable show-header-overflow="tooltip"
                    show-overflow="tooltip" size="mini" stripe>
                    <vxe-table-column :field="items.field" :key="items.field" :title="items.title" :width="items.width"
                        sortable v-for="items in tableColumnReg"></vxe-table-column>
                </vxe-table>
            </div>

            <el-dialog v-el-drag-dialog :append-to-body="true" class="change-pop" :close-on-click-modal="false" title="系统注册"
                :visible.sync="dialogSysRegCodeVisible" width="60%">
                <span style="color: #0095d9">请输入注册码(多个同时输入时回车换行即可)</span>
                <el-input type="textarea" :rows="8" v-model="RegCodestr" style="margin-top: 5px"></el-input>
                <div style="text-align: right; margin-top: 5px">
                    <el-button @click="SaveModel()">确定</el-button>
                    <el-button @click="(dialogSysRegCodeVisible = false), (RegCodestr = '')">取消</el-button>
                </div>
            </el-dialog>
        </el-dialog>

        <!--送检单位修改弹窗-->
        <el-dialog v-el-drag-dialog :append-to-body="true" class="change-pop" :close-on-click-modal="false" title="送检单位修改"
            :visible.sync="dialogNameChangeVisible" width="60%">
            <el-input v-model="hospname"></el-input>
            <span style="color: #0095d9">请输入注册码(多个同时输入时回车换行即可)</span>
            <el-input type="textarea" :rows="8" v-model="RegCode" style="margin-top: 5px"></el-input>
            <div style="text-align: right; margin-top: 5px">
                <el-button @click="ValidateModel()">确定</el-button>
                <el-button @click="(dialogNameChangeVisible = false), (RegCode = '')">取消</el-button>
            </div>
        </el-dialog>

        <!--送检单位修改弹窗-->
        <el-dialog v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" title="地图位置"
            :visible.sync="dialogMapVisible" width="1110px">
            <iframe src="https://api.map.baidu.com/lbsapi/getpoint/"
                style="width: 1100px; height: 750px; overflow: auto"></iframe>
            <div style="text-align: right; margin-top: 5px">
                <el-button @click="dialogMapVisible = false">关闭</el-button>
            </div>
        </el-dialog>
    </div>
</template>

<script>
import XEUtils from "xe-utils";
export default {
    name: "MNG116",
    data() {
        return {
            issuper: false,
            isarea: false,
            isnoarea: false,
            isDisable: false,

            qcode: "",
            hospitaltype: "",
            AreaTxt: "非区域LIS模式",
            Now: [],
            //添加采购、文档、设备中心的筛选
            InvVal: "",
            DevVal: "",
            DocVal: "",
            InvOption: [],
            DevOption: [],
            DocOption: [],

            tableDataHosp: [],
            tableDataHospAll: [],
            tableDataDept: [],
            tableDataDeptAll: [],
            tableDataGroup: [],
            tableColumnHosp: [],
            tableColumnDept: [],
            tableColumnGroup: [],
            hotableData: [],

            loadingHosp: false,
            loadingDept: false,
            loadingGroup: false,
            keyConfig: {
                isDel: true,
                isTab: true,
                isEdit: true,
            },
            keyLocalConfig: {
                isArrow: true,
            },
            selectConfig: { tigger: "row" },
            CurrentHospcode: "",
            CurrentDeptcode: "",
            CurrentGroupId: "",

            Delname: "",
            DelHospname: "",
            DelDeptname: "",
            DelGroupname: "",
            DelItem: "",
            buttonwidth: "",

            HospInfo: {},
            OldHospInfo: {},
            Hospdialogtitle: "医院、院区维护",
            HospdialogForm: false,
            Organdialogtitle: "外送机构参数维护",
            OrgandialogForm: false,
            DeptInfo: {},
            OldDeptInfo: {},
            Deptdialogtitle: "检验科室维护",
            DeptdialogForm: false,
            GroupInfo: {},
            OldGroupInfo: {},
            Groupdialogtitle: "检验工作组维护",
            GroupdialogForm: false,
            updatemethod: ["queryhospitaldetail", "querydeptdetail", "querygroupdetail"],
            hospclass: [],
            hospgroup: [],

            tempHospIndex: 0,
            tempDeptIndex: 0,
            tempGroupIndex: 0,
            actionflag: 0,
            selectflag: 0,
            AddItem: "",

            dialogOrganDelVisible: false,
            dialogDelVisible: false,
            isFirstLoadingHosp: true,
            isFirstLoadingDept: true,
            isFirstLoadingGroup: true,

            //系统注册
            dialogSysRegVisible: false,
            reghospinfo: "",
            tableDataReg: [],
            tableColumnReg: [],
            loadingReg: false,
            dialogSysRegCodeVisible: false,
            RegCodestr: "",
            //送检单位名称修改弹窗
            dialogNameChangeVisible: false,
            hospname: "",
            RegCode: "",
            isbis: "0", // 输血系统隐藏部分控件
            dialogMapVisible: false,
            //机构维护
            CurrentOrganid: "",
            CurrentOrgancode: "",
            tempOrganIndex: 0,
            OrganInfo: {},
            OldOrganInfo: {},
            changeflag: false,
            canchangehosp: true,
            organactionflag: 0,
            customeFDialog: false,
            customeFieldName: "",
            textareamodel: "",
            customeFieldTitle: "自定义字段",
            totalcount: 0,
            //selorganrow:{},
        };
    },
    created() {
        this.isbis = this.$tool.checkBis();
        this.InitPageData();
    },
    updated() {
        this.GetButtonWidth();
        if (this.isFirstLoadingHosp) {
            var selectrow1 = {};
            if (this.AddItem) {
                selectrow1 = this.$refs.xTable1.tableData.filter((item) => item.hospcode == this.AddItem)[0];
                if (selectrow1) {
                    this.isFirstLoadingHosp = false;
                    this.$nextTick(() => {
                        this.$refs.xTable1.setCurrentRow(selectrow1);
                        this.CurrentHospcode = selectrow1.hospcode;
                        this.FindDept();
                        this.DelHospname = selectrow1.hospitalname;
                        this.$refs.xTable1.scrollToRow(selectrow1);
                    });
                }
                this.AddItem = "";
            } else {
                if (this.tempHospIndex > 0) {
                    if (this.tempHospIndex < this.$refs.xTable1.tableData.length) {
                        selectrow1 = this.$refs.xTable1.getData(this.tempHospIndex);
                    } else {
                        selectrow1 = this.$refs.xTable1.getData(this.$refs.xTable1.tableData.length - 1);
                    }
                } else selectrow1 = this.$refs.xTable1.getData(0);
                if (selectrow1) {
                    this.isFirstLoadingHosp = false;
                    this.$nextTick(() => {
                        this.$refs.xTable1.setCurrentRow(selectrow1);
                        this.CurrentHospcode = selectrow1.hospcode;
                        this.FindDept();
                        this.DelHospname = selectrow1.hospitalname;
                        this.$refs.xTable1.scrollToRow(selectrow1);
                    });
                }
            }
        }
        if (this.isFirstLoadingDept) {
            var selectrow2 = {};
            if (this.AddItem) {
                selectrow2 = this.$refs.xTable2.tableData.filter((item) => item.labdeptcode == this.AddItem)[0];
                if (selectrow2) {
                    this.isFirstLoadingDept = false;
                    this.$nextTick(() => {
                        this.$refs.xTable2.setCurrentRow(selectrow2);
                        this.CurrentDeptcode = selectrow2.labdeptcode;
                        this.FindGroup();
                        this.DelDeptname = selectrow2.labdeptname;
                        this.$refs.xTable2.scrollToRow(selectrow2);
                    });
                }
                this.AddItem = "";
            } else {
                if (this.tempDeptIndex > 0) {
                    if (this.tempDeptIndex < this.$refs.xTable2.tableData.length) {
                        selectrow2 = this.$refs.xTable2.getData(this.tempDeptIndex);
                    } else {
                        selectrow2 = this.$refs.xTable2.getData(this.$refs.xTable2.tableData.length - 1);
                    }
                } else selectrow2 = this.$refs.xTable2.getData(0);
                if (selectrow2) {
                    this.isFirstLoadingDept = false;
                    this.$nextTick(() => {
                        this.$refs.xTable2.setCurrentRow(selectrow2);
                        this.CurrentDeptcode = selectrow2.labdeptcode;
                        this.FindGroup();
                        this.DelDeptname = selectrow2.labdeptname;
                        this.$refs.xTable2.scrollToRow(selectrow2);
                    });
                }
            }
        }
        if (this.isFirstLoadingGroup) {
            var selectrow3 = {};
            if (this.AddItem) {
                selectrow3 = this.$refs.xTable3.tableData.filter((item) => item.labgroupid == this.AddItem)[0];
                if (selectrow3) {
                    this.isFirstLoadingGroup = false;
                    this.$nextTick(() => {
                        this.$refs.xTable3.setCurrentRow(selectrow3);
                        this.CurrentGroupId = selectrow3.labgroupid;
                        this.DelGroupname = selectrow3.labgroupname;
                        this.$refs.xTable3.scrollToRow(selectrow3);
                        this.isFirstLoading = false;
                    });
                }
                this.AddItem = "";
            } else {
                if (this.tempGroupIndex > 0) {
                    if (this.tempGroupIndex < this.$refs.xTable3.tableData.length) {
                        selectrow3 = this.$refs.xTable3.getData(this.tempDeptIndex);
                    } else {
                        selectrow3 = this.$refs.xTable3.getData(this.$refs.xTable3.tableData.length - 1);
                    }
                } else selectrow3 = this.$refs.xTable3.getData(0);
                if (selectrow3) {
                    this.isFirstLoadingGroup = false;
                    this.$nextTick(() => {
                        this.$refs.xTable3.setCurrentRow(selectrow3);
                        this.CurrentGroupId = selectrow3.labgroupid;
                        this.DelGroupname = selectrow3.labgroupname;
                        this.$refs.xTable3.scrollToRow(selectrow3);
                        this.isFirstLoading = false;
                    });
                }
            }
        }
    },
    methods: {
        Search() {
            var row = this.$refs.xTable1.getCurrentRow();
            var querycode = this.qcode.toUpperCase();
            this.tableDataHosp = this.tableDataHospAll.filter((item) => item.hospitalname.toUpperCase().indexOf(querycode) > -1 || item.hospcode.toUpperCase().indexOf(querycode) > -1 || item.inputcode.toUpperCase().indexOf(querycode) > -1);
            if (this.hospitaltype)
                this.tableDataHosp = this.tableDataHosp.filter((item) => item.hospitaltype == this.hospitaltype);
            this.$nextTick(() => {
                if (!this.tableDataHosp.find((item) => item.hospcode == row.hospcode)) {
                    var curow = this.$refs.xTable1.getData(0);
                        console.log("curow", curow)
                        this.$refs.xTable1.setCurrentRow(curow);
                        this.CurrentHospcode = curow.hospcode;
                        this.DelHospname = curow.hospitalname;
                        this.FindDept();
                }
            });
        },
        AreaEdit() {
            this.$prompt("需要改变区域LIS模式请输入密码", "密码校验", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                showCancelButton: false,
                cancelButtonClass: "el-button el-button--default el-button--small el-button--primary",
                confirmButtonClass: "el-button el-button--default el-button--small",
                focusCancelButton: false,
            }).then(({ value }) => {
                var flag = value == (this.Now[0] - 0) * 3 + (this.Now[1] - 0) * 6 + (this.Now[2] - 0) * 9;
                if (flag) this.UpdateArea();
                else this.$message.error("密码验证错误!");
            }).catch(() => {
                this.$message("已取消改变区域LIS模式");
            });
        },
        HospCurrentChangeEvent({ row }) {
            this.CurrentHospcode = row.hospcode;
            this.DelHospname = row.hospitalname;
            this.FindDept();
            this.tempHospIndex = this.$refs.xTable1.getRowIndex(row);
        },
        DeptCurrentChangeEvent({ row }) {
            this.CurrentDeptcode = row.labdeptcode;
            this.DelDeptname = row.labdeptname;
            this.FindGroup();
            this.tempDeptIndex = this.$refs.xTable2.getRowIndex(row);
        },
        GroupCurrentChangeEvent({ row }) {
            this.CurrentGroupId = row.labgroupid;
            this.DelGroupname = row.labgroupname;
            this.tempGroupIndex = this.$refs.xTable3.getRowIndex(row);
        },
        OrganCurrentChangeEvent({ row }) {
            this.CurrentOrgancode = row.organcode;
            this.FindOrganDetail(row);
            this.tempOrganIndex = this.$refs.xTableOrgan.getRowIndex(row);
        },
        GetButtonWidth() {
            if (this.$refs.buttondiv) {
                this.buttonwidth = this.$refs.buttondiv.offsetWidth + "px";
            }
        },
        rowClassName({ row, rowIndex }) { },
        InitPageData() {
            this.InitData();
            this.FindHosp();
            //this.FindDept();
            //this.FindGroup();
        },
        InitData() {
            this.$tool
                .request({
                    url: "MNG/MNG1/MNG116",
                    method: "post",
                    data: {
                        action: "InitData",
                    },
                })
                .then((res) => {
                    this.issuper = res.issuper == "1" ? true : false;
                    this.isarea = res.isarea == "1" ? true : false;

                    this.Now = res.sysdate.split("-");
                    this.InvOption = res.invOption;
                    this.DevOption = res.devOption;
                    if (this.isarea) this.AreaTxt = "区域LIS模式";
                    else {
                        this.isnoarea = true;
                        this.AreaTxt = "非区域LIS模式";
                    }
                });
        },
        UpdateArea() {
            this.$tool
                .request({
                    url: "MNG/MNG1/MNG116",
                    method: "post",
                    data: {
                        action: "UpdateArea",
                    },
                })
                .then((res) => {
                    if (res.errcode == "1") {
                        this.isarea = res.area == "1" ? true : false;
                        if (this.isarea) this.AreaTxt = "区域LIS模式";
                        else {
                            this.isnoarea = true;
                            this.AreaTxt = "非区域LIS模式";
                        }
                    } else {
                        this.$confirm(res.errmsg, "提示", {
                            confirmButtonText: "确定",
                            cancelButtonText: "取消",
                            focusCancelButton: false,
                            type: "warning",
                        });
                    }
                });
        },
        OpenDialog(actionflag, selectflag) {
            this.actionflag = actionflag;
            this.selectflag = selectflag;
            if (actionflag == 2 && selectflag == 2) {
                this.isDisable = true;
            } else {
                this.isDisable = false;
            }
            if (actionflag == 4 && selectflag == 1) {
                this.OrgandialogForm = true;
                this.canchangehosp = true;
                this.organactionflag = 0;
                this.changeflag = false;
                this.CurrentOrgancode = "";
                this.tempOrganIndex = 0;
                this.OrganInfo = { downrptunitid1: "0", downrptunitid2: "0" };
                this.OldOrganInfo = { downrptunitid1: "0", downrptunitid2: "0" };
                this.FindOrgan();
            }
            if (actionflag < 3) {
                if (actionflag == 1) {
                    this.HospInfo = { inputcode: "", hospitalna: "" };
                    this.DeptInfo = { inputcode: "" };
                    this.GroupInfo = { inputcode: "", bilabgroupname: "" };
                } else {
                    this.FindDetail(selectflag);
                }
                switch (selectflag) {
                    case 1:
                        this.HospdialogForm = true;
                        break;
                    case 2:
                        if (this.tableDataHosp.length > 0) {
                            this.DeptdialogForm = true;
                        } else {
                            this.$confirm("没有检验医院，不能新增检验科室", "提示", {
                                confirmButtonText: "确定",
                                cancelButtonText: "取消",
                                focusCancelButton: false,
                                type: "warning",
                            });
                        }
                        break;
                    case 3:
                        if (this.tableDataDept.length > 0) {
                            this.GroupdialogForm = true;
                        } else {
                            this.$confirm("没有检验科室，不能新增检验工作组!", "提示", {
                                confirmButtonText: "确定",
                                cancelButtonText: "取消",
                                focusCancelButton: false,
                                type: "warning",
                            });
                        }
                        break;
                }
            }
            if (actionflag == 3) {
                this.FindDetail(selectflag);
                switch (selectflag) {
                    case 1:
                        if (this.tableDataDept.length > 0) {
                            this.$confirm("检验科室项目不为空，不能删除", "提示", {
                                confirmButtonText: "确定",
                                cancelButtonText: "取消",
                                focusCancelButton: false,
                                type: "warning",
                            })
                        } else {
                            this.DelItem = "医院";
                            this.Delname = this.DelHospname + "";
                            this.dialogDelVisible = true;
                        }
                        break;
                    case 2:
                        if (this.tableDataDept.length > 0) {
                            if (this.tableDataGroup.length > 0) {
                                this.$confirm("检验工作组项目不为空，不能删除!", "提示", {
                                    confirmButtonText: "确定",
                                    cancelButtonText: "取消",
                                    focusCancelButton: false,
                                    type: "warning",
                                });
                            } else {
                                this.DelItem = "科室";
                                this.Delname = this.DelDeptname + "";
                                this.dialogDelVisible = true;
                            }
                        } else {
                            this.$confirm("没有需要删除的检验科室", "提示", {
                                confirmButtonText: "确定",
                                cancelButtonText: "取消",
                                focusCancelButton: false,
                                type: "warning",
                            }).catch((e) => {
                                // this.$message({ type: "info", message: "已取消删除检验科室", });
                            });
                        }
                        break;
                    case 3:
                        if (this.tableDataGroup.length > 0) {
                            this.DelItem = "工作组";
                            this.Delname = this.DelGroupname + "";
                            this.dialogDelVisible = true;
                        } else {
                            this.$confirm("没有需要删除的检验工作组!", "提示", {
                                confirmButtonText: "确定",
                                cancelButtonText: "取消",
                                focusCancelButton: false,
                                type: "warning",
                            }).catch((e) => {
                                // this.$message({ type: "info", message: "已取消删除检验工作组", });
                            });
                        }
                        break;
                }
            }
        },
        FindHosp() {
            this.loadingHosp = true;
            this.$tool
                .request({
                    url: "MNG/MNG1/MNG116",
                    method: "post",
                    data: {
                        action: "queryhospital",
                    },
                })
                .then((res) => {
                    this.isFirstLoadingHosp = true;
                    this.tableColumnHosp = res.Cols;
                    this.tableDataHospAll = res.Data;
                    this.tableDataHosp = res.Data;
                    this.totalcount = res.Data.length;
                    if (this.qcode) {
                        var querycode = this.qcode.toUpperCase();
                        this.tableDataHosp = res.Data.filter((item) => item.hospitalname.toUpperCase().indexOf(querycode) > -1 || item.hospcode.toUpperCase().indexOf(querycode) > -1 || item.inputcode.toUpperCase().indexOf(querycode) > -1);
                    }
                    if (this.hospitaltype) this.tableDataHosp = this.tableDataHosp.filter((item) => item.hospitaltype == this.hospitaltype);
                    this.loadingHosp = false;
                    this.FindDept();
                });
        },
        FindDept() {
            this.loadingDept = true;
            this.$tool
                .request({
                    url: "MNG/MNG1/MNG116",
                    method: "post",
                    data: {
                        action: "querylabdept",
                        hospcode: this.CurrentHospcode,
                    },
                })
                .then((res) => {
                    this.isFirstLoadingDept = true;
                    this.tableColumnDept = res.Cols;
                    //this.tableDataDept = res.Data;
                    this.tableDataDeptAll = res.Data;
                    if (this.InvVal || this.DevVal || this.DocVal) this.OrgSearch();
                    else this.tableDataDept = XEUtils.clone(res.Data, true);
                    this.loadingDept = false;
                    this.FindGroup();
                });
        },
        FindGroup() {
            this.loadingGroup = true;
            this.$tool
                .request({
                    url: "MNG/MNG1/MNG116",
                    method: "post",
                    data: {
                        action: "querylabgroup",
                        hospcode: this.CurrentHospcode,
                        deptcode: this.CurrentDeptcode,
                    },
                })
                .then((res) => {
                    this.isFirstLoadingGroup = true;
                    this.tableColumnGroup = res.Cols;
                    this.tableDataGroup = res.Data;
                    this.loadingGroup = false;
                });
        },
        FindDetail(flagnum) {
            this.$tool
                .request({
                    url: "MNG/MNG1/MNG116",
                    method: "post",
                    data: {
                        action: this.updatemethod[flagnum - 1],
                        hospcode: this.CurrentHospcode ? this.CurrentHospcode : "",
                        deptcode: this.CurrentDeptcode ? this.CurrentDeptcode : "",
                        groupid: this.CurrentGroupId ? this.CurrentGroupId : "",
                    },
                })
                .then((res) => {
                    switch (flagnum) {
                        case 1:
                            if (res.Data && res.Data.length > 0) {
                                this.HospInfo = res.Data[0];
                                this.HospInfo.usesecoption = this.HospInfo.usesecoption > 0;
                                this.OldHospInfo = JSON.parse(JSON.stringify(res.Data[0]));
                                this.hospclass = res.Levels;
                                this.hospgroup = res.Groups;
                            }
                            break;
                        case 2:
                            if (res.Data.length > 0) {
                                this.DeptInfo = res.Data[0];
                                this.OldDeptInfo = JSON.parse(JSON.stringify(res.Data[0]));
                            }
                            break;
                        case 3:
                            if (res.Data.length > 0) {
                                this.GroupInfo = res.Data[0];
                                this.OldGroupInfo = JSON.parse(JSON.stringify(res.Data[0]));
                            }
                            break;
                    }
                });
        },

        FindOrgan(organcode) {
            this.$tool
                .request({
                    url: "MNG/MNG1/MNG116",
                    method: "post",
                    data: {
                        action: "queryorganList",
                        hospcode: this.CurrentHospcode ? this.CurrentHospcode : "",
                    },
                })
                .then((res) => {
                    if (res.Data && res.Data.length > 0) {
                        this.hotableData = XEUtils.clone(res.Data, true);
                        if (organcode) {
                            var row = this.hotableData.find((item) => item.organcode == organcode);
                            if (row) {
                                this.$refs.xTableOrgan.setCurrentRow(row);
                                this.OrganCurrentChangeEvent({ row });
                            }
                        } else {
                            var selitemrow = {};
                            if (this.tempOrganIndex > 0) {
                                if (this.tempOrganIndex < this.hotableData.length) {
                                    selitemrow = this.hotableData[this.tempOrganIndex];
                                } else {
                                    selitemrow = this.hotableData[this.hotableData.length - 1];
                                }
                                if (selitemrow) {
                                    this.$refs.xTableOrgan.setCurrentRow(selitemrow);
                                    //this.OrganCurrentChangeEvent({ selitemrow });
                                    this.CurrentOrgancode = selitemrow.organcode;
                                    this.FindOrganDetail(selitemrow);
                                    this.tempOrganIndex = this.$refs.xTableOrgan.getRowIndex(selitemrow);
                                }
                            } else {
                                var row = this.hotableData[0];
                                this.$refs.xTableOrgan.setCurrentRow(row);
                                this.OrganCurrentChangeEvent({ row });
                            }
                            // if(this.organactionflag==3){
                            //     var row = this.hotableData[this.hotableData.length-1]
                            //     this.$refs.xTableOrgan.setCurrentRow(row);
                            //     this.OrganCurrentChangeEvent({ row });
                            // }else{

                            //     var row = this.hotableData[0]
                            //     this.$refs.xTableOrgan.setCurrentRow(row);
                            //     this.OrganCurrentChangeEvent({ row });
                            // }
                        }
                        this.canchangehosp = false;
                    } else {
                        this.$refs.xTableOrgan.clearCurrentRow();
                        this.hotableData = [];
                        this.canchangehosp = true;
                    }
                });
        },
        FindOrganDetail(row) {
            if (row) {
                this.CurrentHospcode = row.hospcode;
                this.CurrentOrgancode = row.organcode;
                this.$tool
                    .request({
                        url: "MNG/MNG1/MNG116",
                        method: "post",
                        data: {
                            action: "queryorganList",
                            hospcode: this.CurrentHospcode,
                            organcode: this.CurrentOrgancode,
                        },
                    })
                    .then((res) => {
                        if (res.Data && res.Data.length > 0) {
                            this.OrganInfo = XEUtils.clone(res.Data[0], true);
                            this.OldOrganInfo = res.Data[0];
                            this.canchangehosp = false;
                        } else {
                            this.OrganInfo = { downrptunitid1: "0", downrptunitid2: "0" };
                            this.OldOrganInfo = { downrptunitid1: "0", downrptunitid2: "0" };
                            this.canchangehosp = true;
                        }
                    });
            } else {
                this.canchangehosp = true;
                this.OrganInfo = { downrptunitid1: "0", downrptunitid2: "0" };
                this.OldOrganInfo = { downrptunitid1: "0", downrptunitid2: "0" };
                this.changeflag = false;
            }
        },
        customefieldDialog(field) {
            this.customeFieldTitle = "自定义字段" + field + "输入";
            if (this.organactionflag == 0) {
                this.organactionflag = 2;
            }
            this.changeflag = true;
            this.customeFDialog = true;
            this.customeFieldName = field;
            switch (this.customeFieldName) {
                case "1":
                    this.textareamodel = this.OrganInfo.customefield1;
                    break;
                case "2":
                    this.textareamodel = this.OrganInfo.customefield2;
                    break;
                case "3":
                    this.textareamodel = this.OrganInfo.customefield3;
                    break;
                case "4":
                    this.textareamodel = this.OrganInfo.customefield4;
                    break;
                case "5":
                    this.textareamodel = this.OrganInfo.customefield5;
                    break;
                case "6":
                    this.textareamodel = this.OrganInfo.customefield6;
                    break;
                case "7":
                    this.textareamodel = this.OrganInfo.customefield7;
                    break;
                case "8":
                    this.textareamodel = this.OrganInfo.customefield8;
                    break;
                case "9":
                    this.textareamodel = this.OrganInfo.customefield9;
                    break;
                case "10":
                    this.textareamodel = this.OrganInfo.customefield10;
                    break;
            }
        },
        customeFieldConfirm() {
            debugger;
            console.log("textareamodel", this.textareamodel);
            switch (this.customeFieldName) {
                case "1":
                    this.OrganInfo.customefield1 = XEUtils.clone(this.textareamodel, true);
                    break;
                case "2":
                    this.OrganInfo.customefield2 = XEUtils.clone(this.textareamodel, true);
                    break;
                case "3":
                    this.OrganInfo.customefield3 = XEUtils.clone(this.textareamodel, true);
                    break;
                case "4":
                    this.OrganInfo.customefield4 = XEUtils.clone(this.textareamodel, true);
                    break;
                case "5":
                    this.OrganInfo.customefield5 = XEUtils.clone(this.textareamodel, true);
                    break;
                case "6":
                    this.OrganInfo.customefield6 = XEUtils.clone(this.textareamodel, true);
                    break;
                case "7":
                    this.OrganInfo.customefield7 = XEUtils.clone(this.textareamodel, true);
                    break;
                case "8":
                    this.OrganInfo.customefield8 = XEUtils.clone(this.textareamodel, true);
                    break;
                case "9":
                    this.OrganInfo.customefield9 = XEUtils.clone(this.textareamodel, true);
                    break;
                case "10":
                    this.OrganInfo.customefield10 = XEUtils.clone(this.textareamodel, true);
                    break;
            }
            //this.OrganInfo.this.customeFieldName.val=this.$refs.customeTextarea.val;
            this.customeFDialog = false;
        },
        //设置高亮行
        HightLightRow(row) {
            if (!!row) {
                this.$refs.xTableOrgan.setCurrentRow(row);
                this.FindOrganDetail(row);
            } else {
                this.$refs.xTableOrgan.setCurrentRow(null);
                this.OrganInfo = { downrptunitid1: "0", downrptunitid2: "0" };
                this.OldOrganInfo = { downrptunitid1: "0", downrptunitid2: "0" };
            }
        },
        organcodeChange(code, name) {
            if (code == this.CurrentHospcode) {
                this.$alert("不能选择自己作为外送目标医院", "提示");
                this.changeflag = false;
                return false;
            }
            this.OrganInfo.organcode = code;
            this.OrganInfo.organname = name;

            if (this.organactionflag == 0) {
                this.organactionflag = 2;
            }
            this.changeflag = true;
        },
        footerMethod({ columns, data }) {
            return [
                columns.map((column, columnIndex) => {
                    if (columnIndex === 0) {
                        return "总计";
                    }
                    if (columnIndex === 2) {
                        return this.totalcount;
                    }
                    return null;
                }),
            ];
        },
        HasChange(val) {
            if (this.organactionflag == 0) {
                this.organactionflag = 2;
            }
            this.changeflag = true;
        },
        rptunitchange1(code, name) {
            this.OrganInfo.downrptunitid1 = code;
            if (this.organactionflag == 0) {
                this.organactionflag = 2;
            }
            this.changeflag = true;
        },
        rptunitchange2(code, name) {
            this.OrganInfo.downrptunitid2 = code;
            if (this.organactionflag == 0) {
                this.organactionflag = 2;
            }
            this.changeflag = true;
        },
        btnadd() {
            this.changeflag = true;
            this.canchangehosp = false;
            this.OrganInfo = {};
            this.OrganInfo.hospcode = this.CurrentHospcode;
            this.OrganInfo.downrptunitid1 = "0";
            this.OrganInfo.downrptunitid2 = "0";
            this.organactionflag = 1;
        },
        btndelete() {
            this.organactionflag = 3;
            var delrow = this.$refs.xTableOrgan.getCurrentRow();
            if (delrow) {
                this.Delname = delrow.organname;
                this.dialogOrganDelVisible = true;
            } else {
                this.$message({
                    message: "请选择医院！",
                    type: "warning",
                });
            }

            // try{
            //     var delrow = this.$refs.xTableOrgan.getCurrentRow();
            //     console.log("delrow",delrow);
            //     this.organactionflag=3;
            //     this.$confirm('确定删除医院名称为<b style="color:red">' + delrow.organname + "</b>的记录吗？", "提示", {
            //     confirmButtonText: "确定",
            //     cancelButtonText: "取消",
            //     dangerouslyUseHTMLString: true,
            //     type: "warning",
            //     })
            //     .then(() => {
            //         debugger;
            //         console.log("dddddddddddddd");

            //         consloe.log("this.organactionflag",this.organactionflag);
            //         this.confirmDel();
            //         consloe.log("zzzzzzzzzzzzzzz")
            //     })
            //     .catch((e) => {
            //         console.log("ccccccccccccc");
            //         this.$message({
            //             type: "info",
            //             message: "已取消删除",
            //         });
            //     });
            // }catch(e){
            //     console.log("error", e);
            // }
        },
        confirmDel() {
            var delrow = this.$refs.xTableOrgan.getCurrentRow();
            if (delrow) {
                var alld = this.$refs.xTableOrgan.tableData;
                var rowindex = alld.indexOf(delrow);
                this.CommiTOrgantips();
                this.$nextTick(() => {
                    this.$refs.xTableOrgan.remove(delrow);
                    let havedata = this.$refs.xTableOrgan.tableData;
                    if (havedata.length > 0) {
                        if (rowindex >= havedata.length) rowindex = havedata.length - 1;
                        let selectrow = havedata[rowindex];
                        //this.selorganrow=XEUtils.clone(selectrow,true) ;
                        this.HightLightRow(selectrow);
                    } else {
                        this.HightLightRow(false);
                    }
                });
            }
        },
        ErrorCatch(e, msg, type) {
            this.$alert(msg + e, "提示", {
                confirmButtonText: "确定",
                type: type ? type : "error",
            });
        },
        CancelChange() {
            //debugger;
            this.changeflag = false;
            this.organactionflag = 0;
            var row = this.$refs.xTableOrgan.getCurrentRow();
            if (row) {
                this.canchangehosp = false;
                this.OrganCurrentChangeEvent({ row });
            } else {
                this.OrganInfo = { downrptunitid1: "0", downrptunitid2: "0" };
                this.canchangehosp = true;
            }
        },
        CommiTOrgantips() {
            var oldinfo = this.OldOrganInfo;
            if (!this.OrganInfo.organcode) {
                this.$alert("请先选择医院！");
                return false;
            }
            var ishave = false;
            if (this.organactionflag < 3) {
                var tatadataall = this.$refs.xTableOrgan.tableData;
                tatadataall.forEach((item) => {
                    if (this.organactionflag == 1) {
                        if (this.OrganInfo.organcode == item.organcode) {
                            ishave = true;
                        }
                    } else if (this.organactionflag == 2) {
                        if (item.organcode != oldinfo.organcode && item.organcode == this.OrganInfo.organcode) {
                            ishave = true;
                        }
                    }
                });
            }

            if (ishave) {
                this.$alert("选择的" + this.OrganInfo.organname + "已存在,请选择其他医院。");
                return false;
            }

            var info = JSON.parse(JSON.stringify(this.OrganInfo));
            this.changeflag = false;
            this.$tool
                .request({
                    url: "MNG/MNG1/MNG116",
                    method: "post",
                    data: {
                        action: "organsave",
                        utype: this.organactionflag,
                        saveinfo: info,
                        oldinfo: oldinfo,
                        hospcode: this.CurrentHospcode,
                    },
                })
                .then((res) => {
                    if (res.errcode == 1) {
                        if (this.organactionflag < 3) {
                            this.$message({
                                message: "保存成功",
                                type: "success",
                            });
                            this.FindOrgan(info.organcode);
                            this.$nextTick(() => {
                                if (this.organactionflag == 2) {
                                    var currentrow = this.$refs.xTableOrgan.afterFullData.find((item) => item.organcode == info.organcode);
                                    //debugger;
                                    if (currentrow) {
                                        this.HightLightRow(currentrow);
                                    }
                                }
                                if (this.organactionflag == 1) {
                                    let havedata = this.hotableData[this.hotableData.length - 1];
                                    //debugger;
                                    this.HightLightRow(havedata);
                                }
                                this.organactionflag = 0;
                            });
                        } else {
                            this.$message({
                                message: "删除成功",
                                type: "success",
                            });
                            this.FindOrgan();
                            this.$nextTick(() => {
                                let havedata = this.hotableData[this.hotableData.length - 1];
                                if (havedata) {
                                    this.HightLightRow(havedata);
                                } else {
                                    this.HightLightRow(false);
                                }
                                this.organactionflag = 0;
                                this.dialogOrganDelVisible = false;
                            });
                        }
                    } else {
                        this.$confirm("保存失败:" + res.errmsg, "提示", {
                            confirmButtonText: "确定",
                            focusCancelButton: false,
                            type: "warning",
                        });
                    }
                })
                .catch((error) => {
                    console.log(error);
                });
        },
        CommitTips() {
            var oldinfo = {};
            if (this.selectflag == 1) {
                if (!this.OldHospInfo.seq) this.OldHospInfo.seq = 10;
                if (!this.OldHospInfo.parentid) this.OldHospInfo.parentid = 0;
                if (!this.OldHospInfo.bldgroupid) this.OldHospInfo.bldgroupid = 0;
                oldinfo = this.OldHospInfo;
            }
            if (this.selectflag == 2) oldinfo = this.OldDeptInfo;
            if (this.selectflag == 3) oldinfo = this.OldGroupInfo;
            var info = {};
            if (this.selectflag == 1) {
                if (!this.HospInfo.seq) this.HospInfo.seq = 10;
                if (!this.HospInfo.parentid) this.HospInfo.parentid = 0;
                if (!this.HospInfo.bldgroupid) this.HospInfo.bldgroupid = 0;
                info = JSON.parse(JSON.stringify(this.HospInfo));
                info.usesecoption = this.HospInfo.usesecoption ? "1" : "0";
            }
            if (this.selectflag == 2) info = this.DeptInfo;
            if (this.selectflag == 3) {
                info = this.GroupInfo;
                info.transtype = info.transtype == "检验组" ? "LIS" : info.transtype == "血库组" ? "BLD" : "BAC";
            }
            if ((this.selectflag == 1 && info.hospcode && info.hosporgid && info.hospitalname) || (this.selectflag == 2 && info.labdeptcode && info.labdeptname) || (this.selectflag == 3 && info.labgroupcode && info.labgroupname)) {
                this.$tool
                    .request({
                        url: "MNG/MNG1/MNG116",
                        method: "post",
                        data: {
                            action: "save",
                            utype: this.actionflag,
                            selecttype: this.selectflag,
                            saveinfo: info,
                            oldinfo: oldinfo,
                            hospcode: this.CurrentHospcode,
                            labdeptcode: this.CurrentDeptcode,
                        },
                    })
                    .then((res) => {
                        this.AddItem = res.keyid;
                        if (res.errcode == 1) {
                            if (this.actionflag < 3) {
                                this.$message({
                                    message: "保存成功",
                                    type: "success",
                                });

                                this.HospdialogForm = false;
                                this.DeptdialogForm = false;
                                this.GroupdialogForm = false;
                                if (this.selectflag == 1) {
                                    this.FindHosp();
                                }

                                if (this.selectflag == 2) this.FindDept();
                                if (this.selectflag == 3) this.FindGroup();
                            } else {
                                this.$message({
                                    message: "删除成功",
                                    type: "success",
                                });
                                this.dialogDelVisible = false;
                                if (this.selectflag == 1) this.FindHosp();
                                if (this.selectflag == 2) this.FindDept();
                                if (this.selectflag == 3) this.FindGroup();
                            }
                        } else {
                            if (this.dialogDelVisible) {
                                this.dialogDelVisible = false;
                            }
                            this.$alert("保存失败:" + res.errmsg);
                        }
                    })
                    .catch((error) => {
                        console.log(error);
                    });
            } else {
                this.$confirm("标红项目不能为空!", "提示", {
                    confirmButtonText: "确定",
                    cancelButtonText: "取消",
                    focusCancelButton: false,
                    type: "warning",
                });
            }
        },
        autofocusEvent(event, name) { },
        mdlnameChange(value) {
            console.log(value);
            var pinyinres = this.$pinyin(value, {
                style: this.$pinyin.STYLE_FIRST_LETTER, // 首字母
                heteronym: true,
            });
            var inputcode = "";
            for (var i = 0, len = pinyinres.length; i < len; i++) {
                if (pinyinres[i].length > 1) {
                    pinyinres[i].sort();
                }
                inputcode += pinyinres[i][0];
            }
            if (this.selectflag == 1) {
                this.HospInfo.inputcode = inputcode.toLocaleUpperCase();
                if (!this.HospInfo.hospitalna) this.HospInfo.hospitalna = value;
            }
            if (this.selectflag == 2) this.DeptInfo.inputcode = inputcode.toLocaleUpperCase();
            if (this.selectflag == 3) {
                // if (!this.GroupInfo.bilabgroupname) this.GroupInfo.bilabgroupname = XEUtils.clone(value, true);
                this.GroupInfo.inputcode = inputcode.toLocaleUpperCase();
            }
        },
        QueryCodena() {
            this.$tool
                .request({
                    url: "MNG/MNG1/MNG116",
                    method: "post",
                    data: {
                        action: "querycodena",
                    },
                })
                .then((res) => {
                    this.$prompt("请输入单位名称！", "单位名称", {
                        confirmButtonText: "确定",
                        cancelButtonText: "取消",
                        showCancelButton: false,
                        cancelButtonClass: "el-button el-button--default el-button--small el-button--primary",
                        confirmButtonClass: "el-button el-button--default el-button--small",
                        focusCancelButton: false,
                        inputValue: res,
                    }).then(({ value }) => {
                        this.UpdateCodena(value);
                    });
                });
        },
        UpdateCodena(value) {
            this.$tool
                .request({
                    url: "MNG/MNG1/MNG116",
                    method: "post",
                    data: {
                        action: "updatecodena",
                        codena: value,
                    },
                })
                .then((res) => {
                    if (res.errcode == "1") {
                        this.$message({
                            message: "修改成功",
                            type: "success",
                        });
                    } else {
                        this.$message.error("失败:" + res.errmsg);
                    }
                })
                .catch((err) => {
                    this.$message.error("失败:" + err);
                });
        },
        QueryRegCode() {
            if (this.isarea) {
                if (!this.CurrentHospcode) {
                    this.$alert("请先选择要注册的医院！", "错误");
                    return false;
                }
            }
            this.dialogSysRegVisible = true;
            this.loadingReg = true;
            this.$tool
                .request({
                    url: "MNG/MNG1/MNG116",
                    method: "post",
                    data: {
                        action: "getregmodel",
                        hospcode: this.CurrentHospcode,
                    },
                })
                .then((res) => {
                    if (res) {
                        this.reghospinfo = res.reghospinfo;
                        this.tableColumnReg = res.RData.Cols;
                        this.tableDataReg = res.RData.Data;
                        this.loadingReg = false;
                    }
                })
                .catch((err) => {
                    this.$message.error("未获取到注册信息:" + err);
                });
        },
        opendialogSysRegCode() {
            this.RegCodestr = "";
            this.dialogSysRegCodeVisible = true;
        },
        SaveModel() {
            if (this.RegCodestr == "") {
                this.$alert("输入的注册码为空！", "错误");
                return false;
            }
            this.loadingReg = true;
            this.$tool
                .request({
                    url: "MNG/MNG1/MNG116",
                    method: "post",
                    data: {
                        action: "savemodel",
                        hospcode: this.CurrentHospcode,
                        regcode: this.RegCodestr,
                    },
                })
                .then((res) => {
                    if (res.errcode == 0) {
                        this.$alert(res.errmsg, "错误");
                    } else {
                        // if (res.errcode == 1) {
                        this.dialogSysRegCodeVisible = false;
                        // }
                        if (res.errmsg != "") {
                            this.$alert(res.errmsg, "错误").then(() => {
                                this.$alert(res.okmsg, "注册成功");
                            });
                        } else {
                            this.$alert(res.okmsg, "注册成功");
                        }
                        if (res.data.length > 0) {
                            for (let i = 0; i < res.data.length; i++) {
                                this.tableDataReg.push(res.data[i]);
                            }
                        }
                        if (res.reghospinfo != "") {
                            this.reghospinfo = res.reghospinfo;
                        }
                    }
                    this.loadingReg = false;
                })
                .catch((err) => {
                    this.$message.error("未获取到注册信息:" + err);
                    this.loadingReg = false;
                });
        },
        //各个中心的过滤
        OrgSearch() {
            this.tableDataDept = this.tableDataDeptAll.filter((item) => {
                return (this.InvVal ? item.invorgid == this.InvVal : true) && (this.DevVal ? item.devorgid == this.DevVal : true) && (this.DocVal ? item.docorgid == this.DocVal : true);
            });
            let that = this;
            setTimeout(() => {
                if (that.tableDataDept.length > 0) {
                    that.CurrentDeptcode = that.tableDataDept[0].labdeptcode;
                    that.$refs.xTable2.setCurrentRow(that.tableDataDept[0]);
                } else {
                    that.CurrentDeptcode = "";
                }
                that.FindGroup();
            }, 1);
        },
        //修改送检单位名称时需验证注册码
        ValidateModel() {
            //修改时允许修改医院
            // if (this.RegCode == "") {
            //     this.$alert("输入的注册码为空！", "错误");
            //     return false;
            // }
            this.$tool
                .request({
                    url: "MNG/MNG1/MNG116",
                    method: "post",
                    data: {
                        action: "ValidateModel",
                        hospcode: this.CurrentHospcode,
                        regcode: this.RegCode,
                        hospname: this.hospname,
                    },
                })
                .then((res) => {
                    if (res.errcode == 0) {
                        this.$alert(res.errmsg, "错误");
                    } else if (res.errcode == 2) {
                        this.$alert(res.errmsg, "提示");
                        this.dialogNameChangeVisible = false;
                        this.HospInfo.hospitalname = this.hospname;
                        this.FindHosp();
                    } else {
                        this.dialogNameChangeVisible = false;
                        if (res.errmsg != "") {
                            this.$alert(res.errmsg, "错误").then(() => {
                                this.$alert(res.okmsg, "注册成功");
                            });
                        } else {
                            this.$alert(res.okmsg, "注册成功");
                        }
                        this.HospInfo.hospitalname = this.hospname;
                        this.mdlnameChange(this.hospname);
                        // if (res.data.length > 0) {
                        //     for (let i = 0; i < res.data.length; i++) {
                        //         this.tableDataReg.push(res.data[i]);
                        //     }
                        // }
                        // if (res.reghospinfo != "") {
                        //     this.reghospinfo = res.reghospinfo;
                        // }
                    }
                    this.loadingReg = false;
                })
                .catch((err) => {
                    this.$message.error("未获取到注册信息:" + err);
                    this.loadingReg = false;
                });
        },
        //在地图上选择医院位置
        ChooseFromMap() {
            //window.clipboardData.setData("Text", this.HospInfo.hospitalname);
            let addr = this.HospInfo.address
            if (!addr) {
                this.HospInfo.address = this.HospInfo.hospitalname;
                this.$nextTick(() => {
                    this.$refs.hospaddress.select();
                    document.execCommand("copy");
                    this.HospInfo.address = addr;
                });
            }
            else {
                this.$refs.hospaddress.select();
                document.execCommand("copy");
            }
            //
            this.dialogMapVisible = true;
            //window.open("http://api.map.baidu.com/lbsapi/getpoint/");
        },
    },
};
</script>

<style scoped>
::v-deep .el-button--primary {
    color: black;
}

::v-deep .vxe-input--wrapper .vxe-input {
    height: auto;
    width: 200px;
    border-radius: 0px;
}

::v-deep .el-button--default.btn-custom-cancel {
    float: right !important;
    margin-left: 10px;
}

::v-deep .vxe-button.type--button {
    display: inline-block;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    background: #fff;
    color: #606266;
    -webkit-appearance: none;
    text-align: center;
    box-sizing: border-box;
    outline: 0;
    margin: 0;
    transition: 0.1s;
    font-weight: 500;
    text-shadow: 0 1px 1px rgba(255, 255, 255, 0.75) !important;
    background-color: #f5f5f5 !important;
    background-image: linear-gradient(to bottom, #ffffff, #e6e6e6) !important;
    background-repeat: repeat-x !important;
    padding: 6px 15px !important;
}

.pagetop {
    left: 0;
    right: 0;
    height: 72px;
    display: -webkit-box;
    -webkit-box-pack: center;
    -webkit-box-align: center;
    border: solid 1px #ccc;
    position: absolute;
    z-index: 99;
}

.pagecenter {
    position: absolute;
    top: 75px;
    width: 100%;
    left: 0;
    bottom: 0px;
    overflow: auto;
}

.middle-center {
    position: absolute;
    height: 100%;
    right: 605px;
    left: 0;
    bottom: 0;
}

.middle-right {
    position: absolute;
    top: 0;
    bottom: 1px;
    width: 600px;
    right: 0px;
    overflow: hidden;
}

table tr td:nth-child(odd) {
    text-align: right;
    white-space: nowrap;
}

table tr td:nth-child(even) {
    text-align: left;
}

table {
    font-size: 12px;
    border-collapse: separate;
    border-spacing: 5px;
}

.autopart {
    right: 840px;
}

::v-deep .el-checkbox__inner::after {
    border: 2px solid #000000 !important;
    box-sizing: content-box;
    content: "";
    border-left: 0 !important;
    border-top: 0 !important;
    height: 7px;
    left: 4px;
    position: absolute;
    top: 1px;
    transform: rotate(45deg) scaleY(0);
    width: 3px;
    transition: transform 0.15s ease-in 0.05s;
    transform-origin: center;
}

::v-deep .el-checkbox__input.is-disabled+span.el-checkbox__label {
    color: #000000;
    cursor: not-allowed;
}

::v-deep .el-checkbox__input.is-disabled .el-checkbox__inner,
.el-checkbox__input.is-disabled.is-checked .el-checkbox__inner+.el-input.is-disabled .el-input__inner {
    background-color: #ffffff !important;
}

.change-pop ::v-deep .el-dialog__header {
    padding: 10px 20px 5px !important;
    line-height: 18px !important;
}

.change-pop ::v-deep .el-dialog__body {
    padding: 0px 20px 10px 20px !important;
}

.change-pop ::v-deep.el-dialog__title {
    font-size: 18px !important;
}

.change-pop ::v-deep .el-dialog__headerbtn {
    top: 15px !important;
}

.change-pop ::v-deep .el-dialog__footer {
    padding: 0px 5px 10px 5px !important;
}

.table-bottom {
    position: absolute;
    left: 0px;
    bottom: 53%;
    z-index: 1;
    overflow: hidden;
    width: 100%;
}

::v-deep .table-bottom .el-button {
    background-color: #fff;
    text-align: center;
    margin-right: 10px;
}

.table-bottom2 {
    position: absolute;
    left: 0px;
    bottom: 3%;
    z-index: 1;
    overflow: hidden;
    width: 100%;
}

::v-deep .table-bottom2 .el-button {
    background-color: #fff;
    text-align: center;
    margin-right: 10px;
}
</style>